/**
 * @param {number} num
 * @return {number}
 */
 var translateNum = function(num) {
   let number = num.toString()  // 注意将数字转换成字符串
   if(number.length === 0) return 0
   let dp = new Array(number.length).fill(0)
   dp[0] = 1
   for(let i = 1;i < number.length;i++){
      if((number[i-1] === '1' && number[i] >= '0' && number[i] <= '9') || (number[i-1] === '2' && number[i] >='0' && number[i] <='5')){
         if(i===1){
            dp[i] = 2
         }else{
            dp[i] = dp[i-1] + dp[i-2]
         }
      }else{
         dp[i] = dp[i-1]
      }
   }
   return dp[number.length-1]
};
console.log(translateNum('12258'));